<template>
    <div class="item-info-wapper1">
        <van-nav-bar
                title="单据物资详情"
                left-text="返回"
                left-arrow
                fixed
                @click-left="onClickLeft"

        >
            <van-icon name="arrow-left" slot="left"/>

<!--            <van-button v-show="status!='P'"-->
<!--                    type="primary"-->
<!--                    round-->
<!--                    size="small"-->
<!--                    slot="right"-->
<!--            >提交-->
<!--            </van-button>-->
            <!--<van-icon name="search" slot="right"/>-->
        </van-nav-bar>
        <div class="item-info-content">
            <div class="item-panel">
                <div class="item-panel-content">
                    <van-panel title="物资明细">
                        <div style="padding: 10px 0px">
                            <div class="clearfix content-line" style="padding-bottom: 10px">
                                <span class="user-line-label">物资编码：</span>
                                <span class="user-line-input">{{ good.itemid }}</span>
                                <!--<span class="user-line-input">物资号</span>-->
                            </div>
                            <div class="clearfix content-line" style="padding-bottom: 10px">
                                <span class="user-line-label">采购方式：</span>
                                <span class="user-line-input">{{ good.refrence }}</span>
                            </div>
                            <div class="clearfix">
                              <span class="user-line-label">物资名称：</span>
                              <span class="user-line-input">{{ good.itemDescription }}</span>
                            </div>
                            <div class="clearfix">
                                <span class="user-line-label">规格型号：</span>
                                <span class="user-line-input">{{ good.itemSpec }}</span>
                            </div>
                            <div class="clearfix content-line" style="padding-bottom: 10px">
                                <span class="user-line-label">单位：</span>
                                <span class="user-line-input">{{ good.unitid }}</span>
                            </div>
                            <div class="clearfix content-line" style="padding-bottom: 10px">
                                <span class="user-line-label">移入库位：</span>
                                <!--<van-field v-model="text" label="文本" />-->
                                <span class="user-line-input">{{ good.recvlocationid }}</span>

<!--                                <div class="user-line-input" style="border:solid 1px #eee;width: 70%">-->
<!--                                    <span class="user-line-label">单位：</span>-->
<!--                                    <van-cell-group>-->
<!--                                        <van-field v-model="locationid" border/>-->
<!--                                    </van-cell-group>-->

<!--                                </div>-->
<!--                                <van-icon name="scan" slot="right" @click="onClickBillId"/>-->
                                <!-- {{ good.recvlocationid }}</van-field> -->
                            </div>
                            <div class="clearfix content-line" style="padding-bottom: 10px">
                                <span class="user-line-label">移出库位：</span>
                                <span class="user-line-input">{{ good.issuelocationid }}</span>
                            </div>
                            <div class="clearfix content-line" style="padding-bottom: 10px">
                                <span class="user-line-label">单位：</span>
                                <span class="user-line-input">{{ good.unitid }}</span>
                            </div>
                            <div class="clearfix content-line">
                                <span class="user-line-label">数量：</span>
                                <span class="user-line-input">{{ good.qtyCurris1 }}</span>

<!--                                <div class="user-line-input" style="border:solid 1px #eee;">-->
<!--                                    <van-cell-group>-->
<!--                                        <van-field v-model="number"/>-->
<!--                                    </van-cell-group>-->

<!--                                </div>-->

                            </div>

<!--                            <div class="clearfix content-line">-->
<!--                                <span class="user-line-label">备注：</span>-->
<!--                                <div class="user-line-input" style="border:solid 1px #eee;">-->
<!--                                            -->
<!--                                </div>-->

<!--                            </div>-->
                        </div>
                    </van-panel>
                </div>
            </div>

        </div>
    </div>
</template>

<script>
  import {
    updateBilldetl,
    findByRecordid,
    findByBillIdAndBarcode,
      findLocationByBarcode
  } from "@/api/Invbillmstr.js";
  import { Toast } from "vant";

  export default {
    name: "DocumentItemInfo",
    data() {
      return {
        activeNames: ["1", "2", "3"],
        good: {},
          locationIdBarCode:"",
        recordid: "",
        status:"",
        locationid: "",
        number: "",
        updata: {}
      };
    },
    methods: {
      onClickLeft() {
        this.$router.push({
          path: "/itemsList"
        });
        // this.$router.back(-1);
      },
        onClickBillId(){
            this.$router.push({
                path: "/scancode",
                query: { params: "documentItemLocationId" ,
                    recordid:this.recordid
                }
            });
        },
      updateBilldetl() {
        this.updata.recordid = this.recordid;
        this.updata.locationid = this.locationid;
        this.updata.number = this.number;

        updateBilldetl(this.updata).then(res => {
          Toast("修改成功");
          location.reload();
        });
      },
      findByRecordid() {
          console.info("findByRecordid:"+this.recordid)
        findByRecordid(this.recordid).then(res => {
          this.good = res.data;
            this.recordid=res.data.recordid
            this.locationid = res.data.issuelocationid;
          this.number = res.data.qtyCurris1;
        });
      },
        findByBillIdAndBarcode() {
            console.info("findByBillIdAndBarcode:"+this.billId+"::::"+this.itemBarCode)
            findByBillIdAndBarcode(this.billId,this.itemBarCode).then(res => {            console.info("findByBillIdAndBarcode:"+this.billId+this.itemBarCode)
                this.good = res.data;
            this.recordid=res.data.recordid
                this.locationid = res.data.recvlocationid;
                this.number = res.data.qtyCurrrecv1;
            });
        },
        findLocationByBarcode(){
            findLocationByBarcode(this.locationIdBarCode).then(res => {
                var dataLocation=res.data;
                console.info(dataLocation);
                this.locationid=dataLocation[0].locationid;
            });
        }
    },
    created() {
      this.recordid = this.$route.query.recordid;
      this.status = this.$route.query.status;
        this.itemBarCode = this.$route.query.itemBarCode;
        this.billId = this.$route.query.billId;
        this.locationIdBarCode=this.$route.query.locationIdBarCode;
      if(this.locationIdBarCode!=null&&this.locationIdBarCode!=''){
          console.info(this.locationIdBarCode)
          this.findLocationByBarcode();
      }

        if(this.itemBarCode!=null&&this.itemBarCode!=''){
          this.findByBillIdAndBarcode();
      }else{
          this.findByRecordid();
      }

    }

  };
</script>

<style scoped lang="scss">
    .item-info-wapper1 {
        position: relative;

        .item-info-content {
            position: relative;
            top: 46px;
            .content-line {
                display: flex;
                align-items: center;
            }
            .user-line-label {
                width: 85px;
                text-align: right;
                font-size: 14px;
                color: #606266;
                line-height: 1;
                /*padding: 0px 12px 10px 0;*/
                box-sizing: border-box;
                display: inline-block;
            }

            .user-line-input {
                position: relative;
                display: inline-block;
                font-size: 14px;
                /*vertical-align: top;*/
                width: calc(100% - 85px);
            }
            .item-panel {
                padding: 20px 20px 0px 20px;
                .item-panel-content {
                    padding: 5px;
                    display: block;
                    background: #fff;
                    border-radius: 4px;
                    font-size: 14px;
                    position: relative;
                    transition: all 0.2s ease-in-out;
                    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
                    border-color: #eee;
                }
            }
        }
    }
</style>
